package itsm.isperp.framework.web.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 验证码的程序服务
 * 
 * 
 */
public class SimpleCaptchaServlet extends HttpServlet {

	private static final long serialVersionUID = 1L;
	private static final String PARAM_HEIGHT = "height";
	private static final String PARAM_WIDTH = "width";
	protected int _width;
	protected int _height;

	public SimpleCaptchaServlet() {
		_width = 140;
		_height = 50;
	}

	@Override
	public void init() throws ServletException {
		if (getInitParameter(PARAM_HEIGHT) != null)
			_height = Integer.valueOf(getInitParameter(PARAM_HEIGHT))
					.intValue();
		if (getInitParameter(PARAM_WIDTH) != null)
			_width = Integer.valueOf(getInitParameter(PARAM_WIDTH)).intValue();
	}

	@Override
	public void doGet(HttpServletRequest httpservletrequest,
			HttpServletResponse httpservletresponse) throws ServletException,
			IOException {
		// Captcha captcha = (new nl.captcha.Captcha.Builder(_width, _height))
		// .addText().addBackground().addNoise().build();
		//
		// httpservletrequest.getSession().setAttribute("simpleCaptcha",
		// captcha);
		// CaptchaServletUtil.writeImage(httpservletresponse,
		// captcha.getImage());
	}

}